<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>催收员客户关系表 管理</title>
    <style type="text/css">
    </style>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>

<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
        <form id="searchBar">
            <div class="fieldset1 clearFix">
                <div class="fieldBox">
                    <div class="label">姓名</div>
                    <div class="field">
                        <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="">
                    </div>
                </div>

                <div class="formBtns notRight">
                    <span id="searchBtn" class="sq-button-round">查询</span>
                    <span id="clearBtn" class="sq-button-round">清空</span>
                    <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
                </div>
            </div>
        </form>
    </div>
    <div id="ligergrid1" class="sq-grid"></div>
</div>

<script type="text/javascript">
    var grid = null;
    var id;//待分数据id
    $(function () {
        var dialog = frameElement.dialog; //调用页面的dialog对象(ligerui对象)
        var dialogData = dialog.get('data');//获取data参数
        if(dialogData){
            id=dialogData.id;
        }

        grid = $("#ligergrid1").ligerGrid({
            url: '<%=path%>/dk/dkquestnelog/assignPeopleList.do',
            method: 'get',
            columns: [
                {display: '姓名', name: 'refRlNm', minWidth: 100, align: 'left', enabledSort: false},
                {display: '操作', name: '', minWidth: 100, align: 'center', enabledSort: false,
                    render:function(rowdata,rowindex,value){
                       return '<a class="sq-button-hasicon" style="cursor: pointer" onclick="assignedTask('+rowdata.id+')">分配</a>'
                    }
                },
            ],
            pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            checkbox: false,
            rownumbers: true,
            allowUnSelectRow: true,
            alternatingRow: true,
        });
        grid.setHeight(100);

        $("#searchBar").ligerForm();

        $("#pageloading").hide();

        /* 查询 */
        $("#searchBtn").click(function (event) {
            var usrnm = $("#cstNm");
            if(usrnm.val()){
                grid.setParm("usrNm", usrnm.val());
            }
            grid.reload();
        });

        /* 清空 */
        $("#clearBtn").click(function (event) {
            $("#resetBtn").click();  //重置 input-text
            var form = liger.get("searchBar");
            form.setData({  //重置select等特殊表单
                "*Cd": " "
            });
        });


    });

    //分配任务
    function assignedTask(_usrId){
        var wait_dialog;
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: {id: id,usrId:_usrId},
            url: '<%=path%>/dk/dkquestnelog/assignTask.do',
            beforeSend: function () {
                wait_dialog = $.ligerDialog.SQalert({
                    content: LogUtils.LOG_CMM_DATA_LOADING,
                    SQ_type: "waitting"
                });
            },
            complete: function (msg) {
                wait_dialog.close();
                top.$.ligerDialog.SQalert({content: "分配成功", SQ_type: "success"});
                parent.$("#clearBtn").click();
                parent.$("#searchBtn").click();
                frameElement.dialog.close();
            }
        });
    }

</script>

</body>
</html>
